const router = require('koa-router')()
const mysql = require('mysql');

var con=mysql.createConnection(
    {
        host:'192.168.42.144',
        port:3306,
        user:'root',
        password:"ddd",
        database:'mydatabase'
    }
)

var obj={};

obj.query=async function(sqlStr,arr){
    return await new Promise((resolve,reject)=>{
        con.query(sqlStr,arr,(err,result)=>{
            if(err){
                reject(err);
            }else{
                resolve(result);
            }
        })
    })
}

module.exports=obj;//! obj公布出去，里面有query方法

